﻿namespace SPFluid.Core.Validation.Extensions
{
    public static class BooleanValidatorExtensions
    {
        public static IGuard<bool> IsTrue(this IGuard<bool> guard)
        {
            return IsValid(guard, true);
        }

        public static IGuard<bool> IsFalse(this IGuard<bool> guard)
        {
            return IsValid(guard, false);
        }

        private static IGuard<bool> IsValid(IGuard<bool> guard, bool expected)
        {
            if (guard.Argument.Value != expected)
            {
                guard.ExceptionHandler.ThrowArgumentOutOfRangeException();
            }

            return guard;
        }
    }
}